import { MyVue } from 'src/wl/my_vue';
import Vue from 'vue';
import { Component, Emit, Prop, Provide, Watch } from 'vue-property-decorator'
import { OrganizationConst } from "src/consts/organization_const";
import { AccManageConst } from "src/consts/acc_manage_const";
import { PopupName } from "src/consts/popup_const";
@Component({})
export default class OrgAddPanel extends MyVue {
    name: string = 'OrgAddPanel';
    formData: any;
    footerFlag: boolean = true;
    rule: Object

    initData(that?: any): void {
        that.formData = WLStore().state.orgShow
        that.formData = {}
        that.rule = {}
    }

    mounted(): void {
    }


    addOrg(): void {
        this.$refs.orgAddForm.validate((valid: Boolean) => {
            if (valid) {
                let sendData: any = this.formData
                sendData.parent = WLStore().state.orgShow.id
                sendData.isContinue = false
                WLDispatch(OrganizationConst.DispatchOrgAdd, this.formData);
            } else {
                WLMessage("必填字段为空,无法新增部门", "warning")
                return false;
            }
        })
    }

    continueAdd(): void {
        let sendData: any = this.formData
        sendData.parent = WLStore().state.orgShow.id
        sendData.isContinue = true
        this.$refs.orgAddForm.validate((valid: Boolean) => {
            if (valid) {
                WLDispatch(OrganizationConst.DispatchOrgAdd, this.formData);
            } else {
                WLMessage("必填字段为空,无法新增部门", "warning")
                return false;
            }
        })
        setTimeout(() => {
            this.$refs.orgAddForm.resetFields();
        }, 500);
    }


    rowClassName(data: any): string {
        if (data.row.selected) {
            return 'selected_row';
        }
        return '';
    }
}